package com.lyl.serviceresume.controller.api;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lyl.commonutils.R;
import com.lyl.serviceresume.entity.ResumeModel;
import com.lyl.serviceresume.service.ResumeModelService;
import com.lyl.vo.order.ResumeModelVoOrder;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 前台简历模板 前端控制器
 * </p>
 *
 * @author 雷艳玲
 * @since 2022-07-24
 */
@RestController
@RequestMapping("/serviceresume/api/model")
public class ResumeApiModelController {

    @Autowired
    ResumeModelService modelService;

    @ApiOperation(value = "查询模板信息")
    @GetMapping("/getDto/{resumeModelId}")
  public  ResumeModelVoOrder getResumeModelDto(@PathVariable("resumeModelId")Long resumeModelId)
    {
        ResumeModel resumeModel = modelService.getById(resumeModelId);
        ResumeModelVoOrder modelVoOrder= new ResumeModelVoOrder();

        BeanUtils.copyProperties(resumeModel,modelVoOrder);
        System.out.println("modelVoOrder:"+modelVoOrder);
        return modelVoOrder;
    }

    @ApiOperation(value = "简历模板分页")
    @PostMapping("{page}/{limit}")
    public R pageQuery(
            @ApiParam(name = "page", value = "当前页码", required = true)
            @PathVariable Long page,

            @ApiParam(name = "limit", value = "每页记录数", required = true)
            @PathVariable Long limit,

            @ApiParam(name = "query", value = "查询对象", required = false)
            @RequestBody(required = false)
                    ResumeModel query){
        System.out.println("查询条件:" + query);

        Page<ResumeModel> pageParam = new Page<>(page, limit);
        Map<String, Object> map = modelService.pageListWeb(pageParam, query);
        return  R.ok().data(map);
    }




}

